package com.mzj.saas.mservice.lock.Repository;

import com.mzj.saas.mservice.lock.entity.SmartLockFingerprint;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;

import javax.transaction.Transactional;
import java.util.List;

public interface SmartLockFingerprintRepository extends PagingAndSortingRepository<SmartLockFingerprint, Long>, JpaSpecificationExecutor<SmartLockFingerprint> {

    List<SmartLockFingerprint> findByLockAuthId(Long lockAuthId);

    List<SmartLockFingerprint> findByLockId(Long lockId);

    SmartLockFingerprint findByLockAuthIdAndFingerprintIndexNum(Long lockAuthId, Integer fingerprintIndexNum);

    Integer countByLockAuthId(Long lockAuthId);

    SmartLockFingerprint findByLockAuthIdAndFingerprintIndex(Long lockAuthId, Integer fingerprintIndex);

    @Transactional
    void deleteByLockAuthId(Long lockAuthId);

    int deleteByLockId(Long lockId);
}
